package com.telit.firecommand.controller;

import com.telit.common.entity.DataReturn;
import com.telit.common.enums.ResultCode;
import com.telit.firecommand.entity.AppTaskFeedback;
import com.telit.firecommand.service.TaskFeedBackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * @author zhouyu
 * @description 任务反馈接口
 */
@RestController
@RequestMapping("/task-feedback")
@Api(tags = "任务反馈接口", description = "task-feedback")
public class TaskFeedBackController {

    @Autowired
    private TaskFeedBackService taskFeedBackService;

    @PostMapping(value = "/addTaskFeedback", produces = "application/json;charset=UTF-8")
    @ApiOperation("app端上传任务反馈数据")
    public DataReturn addTaskFeedback(@RequestParam(value = "files", required = false) List<MultipartFile> files,
                                      @RequestBody @Validated AppTaskFeedback appTaskFeedback) {
        if (taskFeedBackService.addTaskFeedback(appTaskFeedback, files) <= 0) {
            return DataReturn.failure(ResultCode.OPERATE_ERROR.getCode(), "反馈任务失败");
        }
        return DataReturn.ok();
    }

}
//
//    @GetMapping(value = "/detail/{id}",produces = "application/json;charset=UTF-8")
//    @ApiOperation("app端任务信息详情")
//    public DataReturn detail(@PathVariable("id") Long id){
//        return DataReturn.ok(taskFeedBackService.detail(id));
//    }
//
////    @GetMapping(value = "/queryUnReadTaskFeedBack/{userId}",produces = "application/json;charset=UTF-8")
////    @ApiOperation("查询未读火情任务反馈")
////    public DataReturn queryUnReadTaskFeedBack(@PathVariable("userId") Long userId){
////        return DataReturn.ok(taskFeedBackService.queryUnReadTaskFeedBack(userId));
////    }
//}
